package com.yksj.healthtalk.ui;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.math.NumberUtils;
import org.handmark.pulltorefresh.library.PullToRefreshBase;
import org.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener2;
import org.handmark.pulltorefresh.library.PullToRefreshListView;
import org.json.JSONObject;
import org.universalimageloader.core.DisplayImageOptions;
import org.universalimageloader.core.ImageLoader;
import org.universalimageloader.core.assist.FailReason;
import org.universalimageloader.core.assist.ImageLoadingListener;
import org.universalimageloader.core.assist.ImageSize;
import org.universalimageloader.core.assist.MemoryCacheUtil;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.style.ImageSpan;
import android.text.style.UnderlineSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.yksj.healthtalk.comm.RootFragment;
import com.yksj.healthtalk.entity.ATagEntity;
import com.yksj.healthtalk.entity.ImgTagEntity;
import com.yksj.healthtalk.net.http.HttpRestClient;
import com.yksj.healthtalk.net.http.ObjectHttpResponseHandler;
import com.yksj.healthtalk.net.http.RequestParams;
import com.yksj.healthtalk.net.socket.SmartFoxClient;
import com.yksj.healthtalk.services.CoreService;
import com.yksj.healthtalk.ui.app.HTalkApplication;
import com.yksj.healthtalk.ui.chatting.ChatLatelyListActivity;
import com.yksj.healthtalk.ui.chatting.DoctorAndPatientContentActivity;
import com.yksj.healthtalk.ui.interestwall.InterestContentActivity;
import com.yksj.healthtalk.ui.salon.SalonInformationActivity;
import com.yksj.healthtalk.ui.setting.PersonalInformationActivity;
import com.yksj.healthtalk.utils.ActivityUtils;
import com.yksj.healthtalk.utils.FaceParse;
import com.yksj.healthtalk.utils.MessageParseUtil;

/**
 * 消息直播
 * 
 * @author jack_tang
 */
public class NewsHallFragment extends RootFragment implements OnClickListener {
	final List<Map<Object, Object>> mList = new ArrayList<Map<Object, Object>>();
	FragmentManager mFragmentManager;
	Map<Object, Object> mLastMap;//装得fragment
	FaceParse mFaceParse;
	
	//更新消息通知
	final BroadcastReceiver mReceiver = new BroadcastReceiver(){
		public void onReceive(Context context, Intent intent) {
			onUpdateMesgeSize();
		};
	};
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mFragmentManager = getChildFragmentManager();
		mFaceParse = FaceParse.getNotifyFaceParse(getActivity());
		initTabs();
		
	}
	
	@Override
	public void onStart() {
		super.onStart();
		IntentFilter filter = new IntentFilter();
		filter.addAction(CoreService.ACTION_OFFLINE_MESSAGE);
		filter.addAction(CoreService.ACTION_MESSAGE);
		getActivity().registerReceiver(mReceiver,filter);
	}

	@Override
	public void onStop() {
		super.onStop();
		getActivity().unregisterReceiver(mReceiver);
		
	}
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.news_hall_tab_layout, null);
		RadioGroup group = (RadioGroup) view.findViewById(R.id.tab_group);
		group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				switch (checkedId) {
				case R.id.tab1:
					onChangeTab(0);
					break;
				case R.id.tab2:
					onChangeTab(3);//壹健康
					break;
				case R.id.tab3://医患对话
					onChangeTab(2);
					break;
				case R.id.tab4://话题聊天
					onChangeTab(1);
					break;
				case R.id.tab5://医管
					onChangeTab(4);
					break;
				}
			}
		});
		
		initTitleView(view);
		titleTextV.setText("消息直播");
		titleTextV.setTextColor(getResources().getColor(android.R.color.black));
		titleLeftBtn.setText("返回");
		titleLeftBtn.setOnClickListener(this);
		onChangeTab(2);
		return view;
	}

	/**
	 * 初始化选项卡
	 */
	private void initTabs() {
		Bundle bundle = new Bundle();
		bundle.putInt("type", 3);//求医问药
		bundle.putInt("header",R.drawable.notice_3);
		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("parame", bundle);
		map.put("clasname", NewsListFragment.class.getName());
		mList.add(map);
		
		bundle = new Bundle();
		bundle.putInt("type", 0);//话题
		bundle.putInt("header",R.drawable.notice_2);
		map = new HashMap<Object, Object>();
		map.put("parame", bundle);
		map.put("clasname", NewsListFragment.class.getName());
		mList.add(map);
		
		
		bundle = new Bundle();
		bundle.putInt("type", 5);//医患对话
		bundle.putInt("header",R.drawable.notice_1);
		map = new HashMap<Object, Object>();
		map.put("parame", bundle);
		map.put("clasname", NewsListFragment.class.getName());
		mList.add(map);
		
		bundle = new Bundle();
		bundle.putInt("type",4);//壹健康
		bundle.putInt("header",R.drawable.notice_4);
		map = new HashMap<Object, Object>();
		map.put("parame", bundle);
		map.put("clasname", NewsListFragment.class.getName());
		mList.add(map);
		
		bundle = new Bundle();
		bundle.putInt("type",6);//医生馆
		bundle.putInt("header",R.drawable.notice_6);
		map = new HashMap<Object, Object>();
		map.put("parame", bundle);
		map.put("clasname", NewsListFragment.class.getName());
		mList.add(map);
	}

	/**
	 * 改变framgnet
	 * @param index
	 */
	private void onChangeTab(int index) {
		FragmentTransaction ft = mFragmentManager.beginTransaction();
		final Map<Object, Object> map = mList.get(index);
		Fragment fragment = (Fragment) map.get("fragment");//选中fragment
		if (mLastMap != null) {//说明里面有fragment  当前fragment清除掉
			ft.detach((Fragment) mLastMap.get("fragment"));
		}
		if (fragment == null) {
			String name = (String) map.get("clasname");
			Bundle bundle = (Bundle) map.get("parame");
			fragment = Fragment.instantiate(getActivity(), name, bundle);
			if (fragment instanceof NewsListFragment) {
				((NewsListFragment) fragment).setmFaceParse(mFaceParse);
			}
			map.put("fragment", fragment);
			ft.add(R.id.fragmentcontent, fragment);
		} else {
			ft.attach(fragment);
		}
		mLastMap = map;
		ft.commit();
	}
	
	/**
	 * 更新未读消息数量大小
	 */
	private void onUpdateMesgeSize(){
		new AsyncTask<Void,Void,Integer>() {
			@Override
			protected Integer doInBackground(Void... params) {
				return HTalkApplication.getNoReadMesgSize();
			}
			@Override
			protected void onPostExecute(Integer result) {
				titleRightBtn2.setText("我的消息("+result.intValue()+")");
			}
		}.execute();
	}
	
	@Override
	public void onResume() {
		super.onResume();
		onUpdateMesgeSize();
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.title_back:
			getActivity().onBackPressed();
			break;
		case R.id.title_right2://我的消息
			Intent intent = new Intent(getActivity(),ChatLatelyListActivity.class);
			startActivity(intent);
			break;
		}
	}
	/**
	 * 社交场,沙龙会,兴趣墙
	 * @author jack_tang
	 */
	public static class NewsListFragment extends Fragment {
		PullToRefreshListView mRefreshListView;
		ListNewAdapter mListNewAdapter;
		FaceParse mFaceParse;
		ImageLoader mImageLoader;
		int mType;
		public void setmFaceParse(FaceParse mFaceParse) {
			this.mFaceParse = mFaceParse;
		}

		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			mImageLoader = ImageLoader.getInstance();
			mType = getArguments().getInt("type");
		}

		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
				Bundle savedInstanceState) {
			View view = inflater.inflate(R.layout.news_pull_listview_layout,
					null);
			mRefreshListView = (PullToRefreshListView)view.findViewById(R.id.listview);
			mRefreshListView.setOnRefreshListener(new OnRefreshListener2() {
				@Override
				public void onPullDownToRefresh(PullToRefreshBase refreshView) {// 下拉刷新
					doQueryData(String.valueOf(Long.MAX_VALUE), 0);
				}
				@Override
				public void onPullUpToRefresh(PullToRefreshBase refreshView) {// 上拉加载更多
					doQueryData(mListNewAdapter.getLastId(), 1);
				}
			});
			return view;
		}

		@Override
		public void onActivityCreated(Bundle savedInstanceState) {
			super.onActivityCreated(savedInstanceState);
			
			mRefreshListView.setAdapter(mListNewAdapter = new ListNewAdapter(
					getArguments().getInt("header"),
					this, mFaceParse, 
					getLayoutInflater(savedInstanceState),
					mImageLoader));
			mRefreshListView.setRefreshing(true);
			doQueryData(String.valueOf(Long.MAX_VALUE),0);
		}

		private class  ObjectHttp extends ObjectHttpResponseHandler{
			private int type;
			ObjectHttp(int type){
				this.type=type;
			}
			
			@Override
			public Object onParseResponse(String content) {
				if(mType==5){//医患对话
					return parseJsonDataList(content,mType);			
				}else{//话题聊天
					return	parseJsonData(content,mType);
	
				}
			}
			
			@Override
			public void onSuccess(Object response) {
				super.onSuccess(response);
				if(type == 0){
					mListNewAdapter.mList.clear();
				}
				mListNewAdapter.onDataChange(type, (List) response);
			}

			@Override
			public void onFinish() {
				super.onFinish();
				mRefreshListView.onRefreshComplete();
			}
			
		}
		
		/**
		 * 查询数据
		 * @param msgId
		 * @param type
		 */
		private void doQueryData(String msgId, final int type) {
			if(mType==5){
				RequestParams params=new RequestParams();
				params.put("Type", "queryAsk");
				params.put("CHAT_GROUP_ID",msgId);
				HttpRestClient.doHttpNewsRequesDocotor(params,new ObjectHttp(type));
			}else{
				HttpRestClient.doHttpNewsRoomQuery(String.valueOf(mType), msgId,new ObjectHttp(type));
			}
			
		}

		/**
		 * 解析json返回数据
		 * 
		 * @param jsonData
		 */
		private List<Map<String, Object>> parseJsonData(String jsonData,int msgType) {

			List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
			if (jsonData == null)
				return list;
			try {
				org.json.JSONArray jsonArray = new org.json.JSONArray(jsonData);
				for (int i = 0; i < jsonArray.length(); i++) {
					Map<String, Object> map = new HashMap<String, Object>();
					JSONObject jsonObject = jsonArray.getJSONObject(i);
					String id = jsonObject.optString("announcementsHistoryid");
					String content = jsonObject.optString("content");
					String date = jsonObject.optString("date");
					String type = jsonObject.optString("type");
					map.put("msgType", msgType);
					if (NumberUtils.isNumber(type)) {
						map.put("type", NumberUtils.toInt(type));
					} else {
						map.put("type", 4);
					}
					map.put("id", id);
					map.put("time", date);
					if(msgType != 4){
						List<Object> objects = MessageParseUtil.parseToNotifyMessage(content);
						map.put("content", objects);
					}else{
						map.put("content", content);
					}
					list.add(map);
				}
			} catch (org.json.JSONException e) {
				e.printStackTrace();
			}
			return list;
		}
		
		/**
		 * 医患对话
		 * @param jsonData
		 * @param msgType
		 * @return
		 */
		private List<Map<String, Object>> parseJsonDataList(String jsonData,int msgType) {
			List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
			if (jsonData == null)
				return list;
			try {
				org.json.JSONArray jsonArray = new org.json.JSONArray(jsonData);
				for (int i = 0; i < jsonArray.length(); i++) {
					Map<String, Object> map = new HashMap<String, Object>();
					JSONObject jsonObject = jsonArray.getJSONObject(i);
					
					String id = jsonObject.optString("CHAT_GROUP_ID");
					String content = jsonObject.optString("CONTENT");
					String date = jsonObject.optString("date","-1");
					String type = jsonObject.optString("type");
					if (NumberUtils.isNumber(type)) {
						map.put("type", NumberUtils.toInt(type));
					} else {
						map.put("type", 4);
					}
					map.put("id", id);
					map.put("time", date);
					map.put("msgType", msgType);
					if(msgType != 4){
						List<Object> objects = MessageParseUtil.parseToNotifyMessage(content);
						map.put("content", objects);
					}else{
						map.put("content", content);
					}
					list.add(map);
				}
			} catch (org.json.JSONException e) {
				e.printStackTrace();
			}
			return list;
		}

	}

	/**
	 * 列表
	 * @author jack_tang
	 *
	 */
	public static class ListNewAdapter extends BaseAdapter {
		LayoutInflater mInflater;
		FaceParse mFaceParse;
		ImageLoader mImageLoader;
		Drawable mGroupDrawable;
		Drawable mUserDrawable;
		final Drawable mHeaderDrawable;
		final List<Map<String, Object>> mList = new ArrayList<Map<String, Object>>();
		final ImageSize mImageSize;
		Fragment mFragment;
		private DisplayImageOptions createSimpleIsCache;
			
		public ListNewAdapter(int resId,Fragment fragment, FaceParse faceParse,
				LayoutInflater inflater, ImageLoader loader) {
			mFaceParse = faceParse;
			mInflater = inflater;
			mImageLoader = loader;
			mFragment = fragment;
			Resources resources = fragment.getResources();
			int size = resources.getDimensionPixelSize(R.dimen.hall_header_size);
			mImageSize = new ImageSize(size, size);
			
			mGroupDrawable = new BitmapDrawable(resources,BitmapFactory.decodeResource(resources,R.drawable.default_head_group));
			mGroupDrawable.setBounds(0, 0, mImageSize.getWidth(),mImageSize.getHeight());

			mUserDrawable = new BitmapDrawable(resources,BitmapFactory.decodeResource(resources,R.drawable.unkonw_head_mankind));
			mUserDrawable.setBounds(0, 0, mImageSize.getWidth(),mImageSize.getHeight());
			mHeaderDrawable = resources.getDrawable(resId);
			mHeaderDrawable.setBounds(0,0, mHeaderDrawable.getIntrinsicWidth(),mHeaderDrawable.getIntrinsicHeight());
			createSimpleIsCache = DisplayImageOptions.createSimpleIsCache(mFragment.getActivity());
		}

		@Override
		public int getCount() {
			return mList.size();
		}

		@Override
		public Map<String, Object> getItem(int position) {
			return mList.get(position);
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		public void onDataChange(int type, List<Map<String, Object>> list) {
			if (type == 1) {// 添加到最后
				mList.addAll(list);
			} else {
				mList.addAll(0, list);
			}
			notifyDataSetChanged();
		}
		
		public String  getFirstId(){
			if (mList.isEmpty())
				return String.valueOf(Long.MAX_VALUE);
			Map<String, Object> map = mList.get(0);
			if (map == null)
				return String.valueOf(Long.MAX_VALUE);
			return (String) map.get("id");
		}
		public String getLastId() {
			if (mList.isEmpty())
				return String.valueOf(Long.MAX_VALUE);
			Map<String, Object> map = mList.get(mList.size() - 1);
			if (map == null)
				return String.valueOf(Long.MAX_VALUE);
			return (String) map.get("id");
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			ViewHolder holder = null;
			if (convertView == null) {
				holder = new ViewHolder();
				convertView = mInflater.inflate(R.layout.notify_chatting_mesg_layout_item, null);
				holder.contentTxtV = (TextView) convertView.findViewById(R.id.notify_cotent);
				holder.timeTxtV = (TextView) convertView.findViewById(R.id.notify_time);
				holder.contentTxtV.setMovementMethod(LinkMovementMethod.getInstance());
				holder.headerImageView = (ImageView)convertView.findViewById(R.id.user_head);
				holder.view_bg = (LinearLayout)convertView.findViewById(R.id.view_bg);
				convertView.setTag(holder);
			} else {
				holder = (ViewHolder) convertView.getTag();
			}
			onBundData(position, holder);
			return convertView;
		}

		/**
		 * 绑定数据
		 * 
		 * @param position
		 */
		private void onBundData(final int position, ViewHolder holder) {
			Map<String, Object> map = getItem(position);
			Object content = map.get("content");
			
			if(content instanceof List){
				List<Object> list = (List)content;
				SpannableStringBuilder builder = new SpannableStringBuilder();
				for (Object object : list) {
					if (object instanceof String) {
						builder.append(mFaceParse.parseSmileTxt((String) object));
					} else if (object instanceof ATagEntity) {
						ATagEntity aTagEntity = (ATagEntity) object;
						ClickMessageSpan clickMessageSpan = new ClickMessageSpan(
								mFragment, aTagEntity.getType(),
								aTagEntity.getId(), aTagEntity.getContent(),map);
						UnderlineSpan underlineSpan = new UnderlineSpan();
						SpannableString spannableString = new SpannableString(
								aTagEntity.getContent());
						int length = spannableString.length();
						//文字加下划线
						spannableString.setSpan(underlineSpan, 0, length,
								Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
						//加点击事件
						spannableString.setSpan(clickMessageSpan, 0, length,
								Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
						builder.append(spannableString);

					} else if (object instanceof ImgTagEntity) {
						ImgTagEntity aTagEntity = (ImgTagEntity) object;
						String srcImage = aTagEntity.getSrc();// 源图片可能需要下载
						String path = mImageLoader.getDownPathUri(srcImage);
						path =  MemoryCacheUtil.generateKey(path,mImageSize);
						Bitmap bitmap = mImageLoader.getMemoryCache().get(path);
						boolean isNeedDown = false;
						Drawable drawable = null;
						if (bitmap != null) {// 不要下載
							drawable = new BitmapDrawable(bitmap);
							drawable.setBounds(0, 0, mImageSize.getWidth(),mImageSize.getHeight());
						} else {// 下載
							isNeedDown = true;
							if("头像不知名_24.png".equals(aTagEntity.getPlaceHolder())){
								drawable = mUserDrawable;
							}else if("groupdefault_24.png".equals(aTagEntity.getPlaceHolder())){
								drawable=mGroupDrawable;
							}else{
								drawable = mUserDrawable;
							}
						}
						ImageSpan imageSpan = new ImageSpan(drawable);
						SpannableString spannableString = new SpannableString(
								srcImage);
						spannableString.setSpan(imageSpan, 0,
								spannableString.length(),
								Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
						builder.append(spannableString);
						//是否需要下载
						if(isNeedDown){
							int startIndex = builder.getSpanStart(imageSpan);
							int endIndex = builder.getSpanEnd(imageSpan);
							mImageLoader.loadImage(mFragment.getActivity(),
									srcImage, createSimpleIsCache, new SpanImageLoadListener(builder,mImageSize,holder.contentTxtV, srcImage, new int[]{startIndex,endIndex}));
						}
					}
				}
				holder.contentTxtV.setTag(R.id.list, builder);
				holder.contentTxtV.setText(builder);
			}else{//系统消息
				holder.contentTxtV.setText((String)content);
			}
			
			if("-1".equals(map.get("time").toString())){
				holder.headerImageView.setVisibility(View.VISIBLE);
				holder.timeTxtV.setText("点击查看");
				holder.headerImageView.setImageDrawable(mHeaderDrawable);
				holder.timeTxtV.setOnClickListener(new OnClickListener() {
					
					@Override
					public void onClick(View v) {
						Intent intent=new Intent(mFragment.getActivity(),DoctorAndPatientContentActivity.class);
						intent.putExtra("CHAT_GROUP_ID",getItem(position).get("id").toString());
						mFragment.getActivity().startActivity(intent);
					}
				});
			}else{
				holder.headerImageView.setVisibility(View.VISIBLE);
				holder.headerImageView.setImageDrawable(mHeaderDrawable);
				holder.timeTxtV.setText(map.get("time").toString());
			}
		}
	}

	static class ViewHolder {
		ImageView headerImageView;
		TextView contentTxtV;
		TextView timeTxtV;
		LinearLayout view_bg;
	}

	/**
	 * imagespan 图片下載
	 * @author zhao
	 */
	public static class SpanImageLoadListener implements ImageLoadingListener {
		WeakReference<TextView> mReference;
		final SpannableStringBuilder mBuilder;
		String mPath;
		int[] mIndexs;//imagespan 的索引位置
		final ImageSize mImageSize;
		public SpanImageLoadListener(SpannableStringBuilder builder,ImageSize imageSize,TextView textView,String path,int[] indexs) {
			mReference = new WeakReference<TextView>(textView);
			mBuilder = builder;
			mPath = path;
			mIndexs = indexs;
			mImageSize = imageSize;
		}
		@Override
		public void onLoadingStarted() {
		}
		@Override
		public void onLoadingFailed(FailReason failReason) {
		}
		@Override
		public void onLoadingComplete(Bitmap loadedImage) {//更新到ui
			if(loadedImage == null)return;
			TextView textView = mReference.get();
			if(textView != null && (textView.getTag(R.id.list) == mBuilder)){
				BitmapDrawable bitmapDrawable = new BitmapDrawable(loadedImage);
				bitmapDrawable.setCallback(null);
				bitmapDrawable.setBounds(0,0, mImageSize.getWidth(),mImageSize.getHeight());
				ImageSpan imageSpan = new ImageSpan(bitmapDrawable);
				SpannableString spannableString = new SpannableString(mPath);
				spannableString.setSpan(imageSpan,0,spannableString.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
				mBuilder.replace(mIndexs[0], mIndexs[1],spannableString);
				textView.setText(mBuilder);
			}
		}
		@Override
		public void onLoadingCancelled() {
		}
	}

	static class ClickMessageSpan extends ClickableSpan {
		// 类型1群2用户
		int type;
		String id;
		String name;
		Fragment mFragment;
		String msgType;
		private Map<String, Object> map;
		

		public ClickMessageSpan(Fragment fragment, int type, String id,
				String name,Map<String,Object> map) {
			this.type = type;
			this.id = id;
			this.name = name;
			this.mFragment = fragment;
			this.msgType=String.valueOf(map.get("msgType"));
			this.map=map;
		}

		@Override
		public void onClick(View widget) {
			startActivity(id, type, name);
		}

		/**
		 * activity页面跳转类型 在适配器里面进行调用
		 * 
		 * @param id
		 * @param id
		 */
		private void startActivity(String id, int type, String name) {
			Intent intent = null;
			switch (type) {
			case 0:{//兴趣墙
				Activity activity = mFragment.getActivity();
				intent = new Intent(activity,InterestContentActivity.class);
				intent.putExtra("picid",id);
				activity.startActivity(intent);
				break;
			}
			case 1:{// 群跳转
				Activity activity = mFragment.getActivity();
				intent = new Intent(activity,SalonInformationActivity.class);
				intent.putExtra("id",id);
				activity.startActivity(intent);
				}
				break;
			case 2:// 用户资料跳转
				Activity activity = mFragment.getActivity();
				String loginUserId = SmartFoxClient.getLoginUserId();
				if(loginUserId.equals(id)){
					intent = new Intent(activity,PersonalInformationActivity.class);
					activity.startActivity(intent);
				}else{
					ActivityUtils.startUserInfoActivity(activity,mFragment.getFragmentManager(), id);
				}
//				if("5".equals(msgType)&& map.containsKey("id")){
//					intent=new Intent(activity,DoctorAndPatientContentActivity.class);
//					intent.putExtra("CHAT_GROUP_ID", map.get("id").toString());
//					activity.startActivity(intent);
//				}else{
//					String loginUserId = SmartFoxClient.getLoginUserId();
//					if(loginUserId.equals(id)){
//						intent = new Intent(activity,PersonalInformationActivity.class);
//						activity.startActivity(intent);
//					}else{
//						ActivityUtils.startUserInfoActivity(activity,mFragment.getFragmentManager(), id);
//					}	
//				}
			
				break;
			case 3:// 新闻跳转
				break;
			}
		}
	}

}
